<template>
  <div class="order-detail" v-if="order">
    <!-- 操作栏 -->
    <detailAction :order="order"></detailAction>
    <!-- 步骤条 -->
    <detailSteps :order="order"></detailSteps>
    <!-- 物流栏 -->
    <Suspense>
      <!-- 组件加载完毕 -->
      <template #default>
        <detailLogistics
          v-if="[3, 4, 5].includes(order.orderState)"
          :order="order"
        />
      </template>
      <!-- 组件加载中显示 -->
      <template #fallback>
        <div class="loading" style="text-align: center; color: #5bb79c">
          loading...
        </div>
      </template>
    </Suspense>
    <!-- 订单商品信息 -->
    <detailInfo :order="order"></detailInfo>
  </div>
</template>

<script>
import { ref } from 'vue'
import detailAction from './components/detail-action.vue'
import detailSteps from './components/detail-steps.vue'
import detailLogistics from './components/detail-logistics.vue'
import detailInfo from './components/detail-info.vue'
import { useRoute } from 'vue-router'
import { findOrderDetail } from '@/api/order'
export default {
  name: 'MemberOrder',
  components: { detailAction, detailSteps, detailLogistics, detailInfo },
  setup() {
    const order = ref(null)
    // const orderList = ref(null)
    const route = useRoute()
    findOrderDetail(route.params.id).then((data) => {
      order.value = data.result
    })
    // 查询物流信息
    // logisticsOrder(route.params.id).then((data) => {
    //   orderList.value = data.result
    // })
    return { order }
  }
}
</script>
<style scoped lang="less">
.order-detail {
  background-color: #fff;
}
</style>
